#######################################################################
# Copyright 2016 Samsung Electronics All Rights Reserved.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

######################################################################
# Build script for Linux Enrollee Sample App
######################################################################

import os

Import('env')

enrollee_env = env.Clone()
transport = enrollee_env.get('TARGET_TRANSPORT')

######################################################################
# Build flags
######################################################################
enrollee_env.AppendUnique(CXXFLAGS=['-Wall', '-std=c++0x'])

if env.get('RELEASE'):
    enrollee_env.AppendUnique(CCFLAGS=['-Os'])
else:
    enrollee_env.AppendUnique(CCFLAGS=['-g'])

enrollee_env.PrependUnique(CPPPATH=[
    '#/resource/include',
    '#/resource/c_common',
    '#/resource/c_common/oic_malloc/include',
    '#/resource/c_common/oic_string/include',
    '#/resource/oc_logger/include',
    '#/resource/csdk/logger/include',
    '#/resource/csdk/include',
    '#/resource/csdk/security/include',
    '#/resource/csdk/stack/include',
    '#/extlibs/cjson',
    '#/service/easy-setup/inc',
    '#/service/easy-setup/enrollee/linux/wifi',
    '#/service/easy-setup/enrollee/inc',
    '#/service/easy-setup/enrollee/src',
])

enrollee_env.PrependUnique(LIBS=[
    'oc',
    'octbstack',
    'oc_logger',
    'ocsrm',
    'pthread',
    'connectivity_abstraction',
    'coap',
    'ESEnrolleeSDK',
])
if enrollee_env.get('SECURED') == '1':
    enrollee_env.PrependUnique(LIBS=['ocpmapi', 'ocprovision'])
    enrollee_env.AppendUnique(LIBS=['mbedtls', 'mbedx509', 'mbedcrypto'])

enrollee = enrollee_env.Program('enrollee',
                                ['enrolleewifi.c', 'easysetup_x.c'])

enrollee += enrollee_env.ScanJSON('service/easy-setup/sampleapp/enrollee/linux')

Alias('enrollee', enrollee)
env.AppendTarget('enrollee')
enrollee_env.UserInstallTargetExtra(enrollee)
